<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    table,
    td {
      border: 1px solid #000;
    }

    table {
      border-collapse: collapse;
    }

    td {
      padding: 0 20px;
      line-height: 45px;
    }
  </style>
</head>

<body>
  <!-- <table>
    <tr>
      <td>姓名</td>
      <td>语文</td>
      <td>数学</td>
      <td>英语</td>
    </tr>
  </table> -->
</body>
<script>
  // 3.  有一个二维数组
  var list = [
    // ["姓名", "语文", "数学", "英语", "总和"],
    ["张三", 55, 66, 77],
    ["李四", 67, 89, 90],
    ["王五", 96, 50, 87],
  ]
  // 根据二维数组  动态生成表格
  document.write("<table>")
  for (i = 0; i < list.length; i++) {
    document.write("<tr>")
    var item = list[i];
    var sum = 0;
    for (j = 0; j < item.length; j++) {
      document.write('<td>' + item[j] + '</td>');
      if (j == 0) {
        continue;
      }
      sum += item[j];
    }
    document.write('<td>' + sum + '</td>')

    document.write("</tr>")
  }
  document.write("</table>")

</script>

</html>